package config
{
	import kernel.config.ConfigData;
    /**
     * 与网络有关的配置 
     * @author 黄孟柱
     * 
     */    
    public class NetConfig
    {
        private static var _ins:NetConfig;
        
        private var xml:XML;
        public function NetConfig()
        {
            initialized();
        }
        
        public static function get instance():NetConfig
        {
            if( _ins == null )
            {
                _ins = new NetConfig();
            }
            return _ins;
        }
        
        private function initialized():void
        {            
            xml = ConfigData.getXML( "netConfig" );
        }
        public function getSer( id:int = -1 ):Array
        {
            var s:XMLList = xml.socket.s;
            var len:int = s.length();
            if( id == -1 )
            {
                id = int( Math.random() * len );
            }           
            if( id >= len )
            {
                id = len - 1;
            }
            
            return [ String(s[id].ip),String(s[id].port) ];
        }
    }
}